package com.sjc.counter.v1;

import com.sjc.counter.entity.RequestInfo;

/**
 * @Classname Demo
 * @Description
 * @Date 2020/5/1 15:45
 * @Created by SangJiacun
 */
public class Demo {
    public static void main(String[] args) {
        MetricsStorage storage = new RedisMetricsStorage();

        ConsoleReporter consoleReporter = new ConsoleReporter(storage);
        consoleReporter.startRepeatedReport(60,60);

        EmailReporter emailReporter = new EmailReporter(storage);
        emailReporter.addToAddress("sangjiacun@gmail.com");
        emailReporter.startDailyReport();

        MetricsCollector collector = new MetricsCollector(storage);
        collector.recordRequest(new RequestInfo("register",123,10234));
        collector.recordRequest(new RequestInfo("register",223,11234));
        collector.recordRequest(new RequestInfo("register",423,12234));
        collector.recordRequest(new RequestInfo("login",23,12434));
        collector.recordRequest(new RequestInfo("login",1223,14234));

        try {
            Thread.sleep(100000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
